﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;


namespace PloobsEngine.SceneControl
{
    public class BlurPostEffect : IPostEffect
    {
        #region IPostEffect Members

        private Effect blur;        
        private SpriteBatch spriteBatch;

        public void init(EngineStuff engine)
        {
            this.blur = EngineStuff.InternalContentManager.GetAsset<Effect>("blur");
            spriteBatch = EngineStuff.SpriteBatch;
        }

        public void Draw(IRenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Rectangle screenRec, IWorld world)
        {
            spriteBatch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.SaveState);
            {
                // Apply the post process shader
                blur.Begin();
                {
                    blur.CurrentTechnique.Passes[0].Begin();
                    {
                        //blur.Parameters["BlurDistance"].SetValue();
                        spriteBatch.Draw(rHelper[PrincipalConstants.CurrentImage], screenRec, Color.White);
                        blur.CurrentTechnique.Passes[0].End();
                    }
                }
                blur.End();
            }
            spriteBatch.End();
            
            
        }

        #endregion
    }
}
